<!DOCTYPE html>
<html lang="zh-cn">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <link rel="shortcut icon" href="../../docs/logo.png">
    <script src="../../build/image3D.js"></script>
    <title>坐标系 | 测试</title>

    <!-- 顶点着色器 -->
    <script type='x-shader/x-vertex' id='vs'>
        attribute vec4 a_position;

        void main(){
            gl_Position = a_position;
            gl_PointSize = 50.0;
        }
    </script>

    <!-- 片段着色器 -->
    <script type='x-shader/x-fragment' id='fs'>
        precision mediump float;
        uniform vec4 u_color;

        void main(){
            gl_FragColor = u_color;
        }
    </script>

</head>

<body>

    <h2>
        Tips:你应该看见三个正方形，从前到后，从左下角到右上角，依次是蓝、绿、红！
    </h2>

    <canvas width=200 height=200>非常抱歉，您的浏览器不支持canvas!</canvas>

    <script>

        var core = image3D.core(document.getElementsByTagName('canvas')[0]);

        // 启用着色器
        core.shader(
            document.getElementById('vs').innerHTML,
            document.getElementById('fs').innerHTML
        );

        // 获取画笔
        var painter = core.painter();

        painter.openDeep();

        // 绘制一个绿点
        core.setAttribute4f('a_position', 0.2, 0.2, 0, 1);
        core.setUniform4f('u_color', 0, 1, 0, 1)
        painter.points(0, 1);

        // 绘制一个红点
        core.setAttribute4f('a_position', 0.3, 0.3, 1, 1);
        core.setUniform4f('u_color', 1, 0, 0, 1);
        painter.points(0, 1);

        // 绘制一个蓝点
        core.setAttribute4f('a_position', 0.1, 0.1, -1, 1);
        core.setUniform4f('u_color', 0, 0, 1, 1);
        painter.points(0, 1);

    </script>

</body>

</html>
